from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
import logging

class StartingPoint(Room):
    
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        # build list of actions
        #self.add_action(In)
        self.add_action(choosePlayerMale)
        self.add_action(choosePlayerFemale)   
    # return description of room.
    def get_description(self):
        return '''
        Choose your player.
        '''
    # return image of room
    def get_image(self):
        return ''
    
    
class StartingPointHandler(BaseHandler):
        # override default template to go to to startingroom.html
    def get_template(self):
        return 'startingroom.html'

    # return class to use to create a new instance of this room
    def get_room_class(self):
        return StartingPoint

# define actions for this room
'''class In(Action):
    def __init__(self):
        Action.__init__(self, "In")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go Inside"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'entrancehall'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
'''
class choosePlayerMale(Action):
    def __init__(self):
        Action.__init__(self, "choosePlayerMale")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Choose Sobine"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'startvilla'
    
    def get_player_name(self):
        return 'Sobine'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    def do_action(self,game,room,request):
        player = game.get_player()
        playerName = request.get("player")
        #playerName = "Joe"
        logging.info("PlayerName: " + playerName)
        playerGender="F"
        if(playerName == "Sobine"): 
            playerGender = "M"
        if(playerGender == "F"):
            playerPosessionPronoun = "her"
            playerThirdPersonSingularPronoun = "she"
        else:
            playerPosessionPronoun = "his"
            playerThirdPersonSingularPronoun = "he"
        player.setPlayerName(playerName)
        player.setPlayerGender(playerGender)
        player.setPlayerPosessionPronoun(playerPosessionPronoun)
        player.setPlayerThirdPersonSingularPronoun(playerThirdPersonSingularPronoun)
        #logging.info("Finished setting all the extra player parameters")
        #self.update('get')
    
    
class choosePlayerFemale(Action):
    def __init__(self):
        Action.__init__(self, "choosePlayerFemale")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Choose Ady"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'startvilla'
    
    def get_player_name(self):
        return 'Ady'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    def do_action(self,game,room,request):
        player = game.get_player()
        playerName = request.get("player")
        #playerName = "Joe"
        logging.info("PlayerName: " + playerName)
        playerGender="F"
        if(playerName == "Sobine"): 
            playerGender = "M"
        if(playerGender == "F"):
            playerPosessionPronoun = "her"
            playerThirdPersonSingularPronoun = "she"
        else:
            playerPosessionPronoun = "his"
            playerThirdPersonSingularPronoun = "he"
        player.setPlayerName(playerName)
        player.setPlayerGender(playerGender)
        player.setPlayerPosessionPronoun(playerPosessionPronoun)
        player.setPlayerThirdPersonSingularPronoun(playerThirdPersonSingularPronoun)
        #logging.info("Finished setting all the extra player parameters")
        #self.update('get')